﻿@using CommandLib
@model FindArtInfo.Models.PartialPagingModel

<div class="cat_row">
    <div id="divPager" style="width: 100% ! important; min-height: 0px ! important; text-align: center; margin-left: 0px; font-size: 11px ! important;font-weight: bold">           
        <span style="text-align:center">                                 
            @{                                        
                int totalPage = Model.TotalPage;
                int pageIndex = Model.PageIndex;                
            }
            @if (totalPage > 1)
            {
                if (pageIndex > 1)
                {
                    string url1 = string.Format("../../{0}{1}pageIndex={2}", Utils.GetUrlByLanguage(CookiesStore.GetCookies(Constants.Cookie.COOKIE_LANGUAGE)), Model.Url, "1");         
                    <a href="@url1" style = "margin-left:5px;color:#F20000; padding-left: 7px; padding-right: 7px"><<</a>                    
                    string url2 = string.Format("../../{0}{1}&pageIndex={2}", Utils.GetUrlByLanguage(CookiesStore.GetCookies(Constants.Cookie.COOKIE_LANGUAGE)), Model.Url, (pageIndex - 1));
                    <a href="@url2" style = "margin-left:5px;color:#F20000; padding-left: 7px; padding-right: 7px"><</a>                    
                }
                var startPoint = (totalPage < 12) ? 1 : ((pageIndex > 10) ? pageIndex : 1);
                var endPoint = (totalPage < 11) ? totalPage : ((pageIndex > 10) ? pageIndex + 10 : 11);
                for (var page = startPoint; page <= endPoint; page++)
                {
                    if (page == pageIndex)
                    {
                        string url3 = string.Format("../../{0}{1}&pageIndex={1}", Utils.GetUrlByLanguage(CookiesStore.GetCookies(Constants.Cookie.COOKIE_LANGUAGE)), Model.Url, page);                                                                          
                        <a href="@url3" style = "margin-left:5px;color:#000; text-decoration: none; padding-left: 7px; padding-right: 7px">@page</a>
                    }
                    else
                    {
                        string url4 = string.Format("../../{0}{1}&pageIndex={2}", Utils.GetUrlByLanguage(CookiesStore.GetCookies(Constants.Cookie.COOKIE_LANGUAGE)), Model.Url, page);                        
                        <a href="@url4" style = "margin-left:5px;color:#F20000; padding-left: 7px; padding-right: 7px">@page</a>
                    }
                }
                if (pageIndex < totalPage)
                {
                    string url5 = string.Format("../../{0}{1}&pageIndex={2}", Utils.GetUrlByLanguage(CookiesStore.GetCookies(Constants.Cookie.COOKIE_LANGUAGE)), Model.Url, (pageIndex + 1)); 
                    <a href="@url5" style = "margin-left:5px;color:#F20000; padding-left: 7px; padding-right: 7px;">></a>                    
                    string url6 = string.Format("../../{0}{1}&pageIndex={2}", Utils.GetUrlByLanguage(CookiesStore.GetCookies(Constants.Cookie.COOKIE_LANGUAGE)), Model.Url, totalPage); 
                    <a href="@url6" style = "margin-left:5px;color:#F20000; padding-left: 7px; padding-right: 7px">>></a> 
                }
            }     
        </span>   
    </div>
</div>
